'use strict';
const bcrypt = require('bcryptjs');

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    // 创建管理员账号
    const adminPassword = await bcrypt.hash('admin123', 10);
    await queryInterface.bulkInsert('users', [
      {
        username: 'admin',
        password: adminPassword,
        fullName: '系统管理员',
        email: 'admin@example.com',
        role: 'admin',
        status: 'active',
        createdAt: new Date(),
        updatedAt: new Date()
      }
    ]);
  },

  async down(queryInterface, Sequelize) {
    // 删除管理员账号
    await queryInterface.bulkDelete('users', { username: 'admin' });
  }
};
